"use strict";
const way = require("./utils/way");
const time = require("./utils/time");
const HomeCtl = require("./controller/home");

//查询用户是否预约
exports.findUser = async (context) => {
  return await way.execute(HomeCtl, "findUser", context);
};


//去预约
exports.goOrder = async (context) => {
  return await way.execute(HomeCtl, "goOrder", context);
};

//服务器时
exports.findServerTime = async (context) => {
  let timestamp = new Date().getTime();
  let stageType = 1

  if (timestamp >= time.getChiaTime(new Date('2024/06/03 00:00:00'))) {
    stageType = 2
  }

  if (timestamp >= time.getChiaTime(new Date('2024/06/05 00:00:00'))) {
    stageType = 3
  }

  if (timestamp >= time.getChiaTime(new Date('2024/06/14 00:00:00'))) {
    stageType = 4
  }
  return { code: 200, msg: "成功", data: { timestamp, stageType } };
};


exports.deleteData = async (context) => {
  return await way.execute(HomeCtl, "deleteOrder", context);
};